<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <ui:composition template="/template/DefaultTemplate.xhtml">
        <ui:define name="content">
            <h:form >
                <p:panel id="shippingorderspanel" header="All Shipping Orders For Sales Order #{salesOrderEntityController.selected.id}" >
                    <p:messages />
                    <p:dataTable value="#{shippingOrderEntityController.allShippingOrders}" var="item" 
                                 selection="#{shippingOrderEntityController.shippingOrdersToBill}">
                        <p:column selectionMode="multiple" /> 

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListShippingOrderEntityTitle_id}"/>
                            </f:facet>
                            <h:outputText value="#{item.id}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListShippingOrderEntityTitle_salesOrder}"/>
                            </f:facet>
                            <h:outputText value="#{item.salesOrder}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListShippingOrderEntityTitle_address}"/>
                            </f:facet>
                            <h:outputText value="#{item.address.address}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListShippingOrderEntityTitle_dateToShip}"/>
                            </f:facet>
                            <h:outputText value="#{item.dateToShip}">
                                <f:convertDateTime pattern="MM/dd/yyyy" />
                            </h:outputText>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListShippingOrderEntityTitle_status}"/>
                            </f:facet>
                            <h:outputText value="#{item.status}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Billing Request"/>
                            </f:facet>
                            <h:commandLink value="#{item.billingRequest.id}" action="/entities/billingRequestEntity/View">
                                <f:setPropertyActionListener target="#{billingRequestEntityController.current}" value="#{item.billingRequest}" />
                                <f:setPropertyActionListener target="#{shippingOrderEntityController.current}" value="#{item.packingOrder.shippingOrder}" />
                            </h:commandLink>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Packing Order"/>
                            </f:facet>
                            <h:commandLink value="#{item.packingOrder.id}" action="/entities/packingOrderEntity/View">
                                <f:setPropertyActionListener target="#{packingOrderEntityController.current}" value="#{item.packingOrder}" />
                                <f:setPropertyActionListener target="#{shippingOrderEntityController.current}" value="#{item.packingOrder.shippingOrder}" />
                            </h:commandLink>
                        </p:column>
                        
                    </p:dataTable>
                </p:panel>
                <br />
                <p:commandButton ajax="false" action="/entities/salesOrderEntity/View.xhtml" value="Back to Sales Order" immediate="true"/>
                &nbsp;
                <p:commandButton action="#{shippingOrderEntityController.generateBillingRequests}" 
                                 value="Generate Billing Request"
                                 update="@form:shippingorderspanel"/>
            </h:form>
        </ui:define>
    </ui:composition>

</html>
